package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@Api(tags = "查询商家状态")
@RequestMapping("/admin/shop")
public class ShopController {
    @Autowired
    RedisTemplate redisTemplate;

    @ApiOperation("商家查看店铺状态")
    @GetMapping("/status")
    public Result status(){
        ValueOperations valueOperations = redisTemplate.opsForValue();
        Integer s = (Integer)  valueOperations.get("SHOP_STATUS");
        return Result.success(s);
    }
    @ApiOperation("商家修改店铺状态")
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable Integer status){
        ValueOperations valueOperations = redisTemplate.opsForValue();
        valueOperations.set("SHOP_STATUS",status);
        return Result.success();
    }
}
